using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using DTO;
using System.Data;

namespace DAOLayer
{
    public class DauSachDao 
   {
          public void ThemDauSach(DauSachDto ds)
        {
            OleDbConnection cn = Database.ConnectionData();
            string str = "Insert into DauSach (Isbn,TuaSach,TheLoai,TacGia,NamXB,NhaXB,TriGia,TinhTrang) values(?,?,?,?,?,?,?,?)";
            OleDbCommand cmd = new OleDbCommand(str, cn);
            cmd.Parameters.Add("@Isbn", OleDbType.Integer);
            cmd.Parameters[0].Value = ds.Isbn;
            cmd.Parameters.Add("@TuaSach", OleDbType.WChar);
            cmd.Parameters[1].Value = ds.TuaSach;
            cmd.Parameters.Add("@TheLoai", OleDbType.Integer);
            cmd.Parameters[2].Value = ds.TheLoai;
            cmd.Parameters.Add("@TacGia", OleDbType.WChar);
            cmd.Parameters[3].Value = ds.TacGia;
            cmd.Parameters.Add("@NamXB", OleDbType.Integer);
            cmd.Parameters[4].Value = ds.NamXB;
            cmd.Parameters.Add("@NhaXB", OleDbType.WChar);
            cmd.Parameters[5].Value = ds.NhaXB;
            cmd.Parameters.Add("@TriGia", OleDbType.Double);
            cmd.Parameters[6].Value = ds.TriGia;
            cmd.Parameters.Add("@TinhTrang", OleDbType.Integer);
            cmd.Parameters[7].Value = ds.TinhTrang;

            cmd.ExecuteNonQuery();
            cn.Close();

           
        }
    }
}
